package network;

import java.io.IOException;
import java.net.SocketException;
import java.util.HashMap;
//词典翻译
public class UdpDictSrever extends UdpEchoServer{
    //start方法完全从父类继承下来的

    private HashMap<String,String> hashMap = new HashMap<>();

    public UdpDictSrever(int port) throws SocketException {
        super(port);
        hashMap.put("cat", "小猫");
        hashMap.put("brid", "小鸟");
        hashMap.put("dog", "小狗");
        //此处可以无限添加英汉键值对
    }
    //process方法需要重写，加入自己的业务逻辑


    @Override
    public String process(String request) {
        return hashMap.getOrDefault(request,"查找的单词不存在");
    }

    public static void main(String[] args) throws IOException {
        UdpDictSrever srever = new UdpDictSrever(9090);
        srever.start();
    }

}
